@extends('system.frame_layout')
<?php $parent_menu = "个人信息"; $menu_selected = "修改密码";?>

@section('content')
    <div id="content-panel">
        <div class="row">
            <div class="col-xs-12">
                <div class="portlet light bordered">
                    <div class="portlet-title">
                        <div class="caption">
                            <i class="icon-social-dribbble font-dark hide"></i>
                            <span class="caption-subject font-dark bold">修改密码 Change Password</span>
                        </div>
                    </div>
                    <div class="portlet-body">
                        <div class="form-group">
                            <form role="form" action="{{route('sys.pass.save')}}" method="post" id="modifyPass">
                                <div class="form-body">
                                    {{ csrf_field() }}
                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            选择修改密码类型 - Select Your Password Type
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="mt-radio-inline">
                                                <label class="mt-radio">
                                                    <input type="radio" name="type" value="1" checked> 修改登录密码
                                                    <span></span>
                                                </label>
                                                <label class="mt-radio">
                                                    <input type="radio" name="type" value="2"> 修改交易密码
                                                    <span></span>
                                                </label>
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            原密码 - Real Password
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input type="text" class="form-control" name="oldpass" id="oldpass"
                                                       value="" placeholder="请输入登录或交易密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro" for="oldpass"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            新密码 - New Password
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input type="password" class="form-control" name="newpass" id="newpass"
                                                       value="" placeholder="请输入新的密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro" for="newpass"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <label class="col-xs-12 title" for="exampleInputPassword1">
                                            确认新密码 - Confirm Password
                                        </label>
                                        <div class="col-md-4 col-xs-12">
                                            <div class="input-group">
                                                    <span class="input-group-addon">
                                                        <i class="iconfont icon-bixuan-copy font-red"></i>
                                                    </span>
                                                <input type="password" class="form-control" name="repass" id="repass"
                                                       value="" placeholder="请确认新的密码">
                                            </div>
                                        </div>
                                        <div class="col-xs-12 col-md-6">
                                            <label class="label-intro" for="repass"></label>
                                        </div>
                                    </div>

                                    <div class="row input-row">
                                        <div class="col-xs-12">
                                            <button type="submit" class="btn blue-madison">
                                                <i class="iconfont icon-duihao"></i>&nbsp;立即保存
                                            </button>
                                        </div>
                                    </div>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
@endsection

@section('footer')
    <script type="text/javascript">
        $("#modifyPass").validate({
            rules: {
                oldpass: {
                    required: true,
                    maxlength: 50
                },
                newpass: {
                    required: true,
                    maxlength: 50
                },
                repass: {
                    required: true,
                    maxlength: 50,
                    equalTo: "#newpass"
                }
            }, errorPlacement: function (error, element) {
                $(element).closest("form").find("label[for='" + element.attr("id") + "']").html(error);
            },
            submitHandler: function (form) {
                $(form).ajaxSubmit({
                    dataType: "json",
                    type: "post",
                    success: function (data) {
                        if (data.code == 0) {
                            toastr["success"](data.msg);
                            setInterval(function () {
                                window.location.reload();
                            }, 2000);
                        } else {
                            toastr["error"](data.msg);
                        }
                    }
                });
            }
        });
    </script>
@endsection